package com.led_on_off.led;

import ohos.aafwk.content.Intent;
import ohos.aafwk.content.IntentParams;
import ohos.bluetooth.BluetoothRemoteDevice;
import ohos.event.commonevent.CommonEventData;
import ohos.event.commonevent.CommonEventSubscribeInfo;
import ohos.event.commonevent.CommonEventSubscriber;

public class MyCommonEventSubscriber extends CommonEventSubscriber {
    public MyCommonEventSubscriber(CommonEventSubscribeInfo subscribeInfo) {
        super(subscribeInfo);
    }

    @Override
    public void onReceiveEvent(CommonEventData data) {
        if (data == null) {
            return;
        }
        Intent info = data.getIntent();
        if (info == null) {
            return;
        }
        //获取系统广播的action
        String action = info.getAction();
        //判断是否为扫描到设备的广播
        if (BluetoothRemoteDevice.EVENT_DEVICE_DISCOVERED.equals(action)) {
            IntentParams myParam = info.getParams();
            BluetoothRemoteDevice device = (BluetoothRemoteDevice) myParam.getParam(BluetoothRemoteDevice.REMOTE_DEVICE_PARAM_DEVICE);
        }
    }
}
